import random

from constant import SCREEN_X, SCREEN_Y, BOARD_SIZE, INIT_OFFSET


class BulletLine:
    def __init__(self, pygame):
        self.rect = pygame.Rect(-BOARD_SIZE * INIT_OFFSET, 0, BOARD_SIZE, BOARD_SIZE)
        self. all_pos_hori = []
        self. all_pos_verti = []

    def remove(self):
        self.rect.x = -BOARD_SIZE * INIT_OFFSET

    def set(self):
        if self.rect.x == -BOARD_SIZE * INIT_OFFSET:

            # 不靠墙太近 25 ~ SCREEN_X-25 之间
            for pos in range(BOARD_SIZE, SCREEN_X - BOARD_SIZE, BOARD_SIZE):
                self.all_pos_hori.append(pos)

            for pos in range(BOARD_SIZE, SCREEN_Y - BOARD_SIZE, BOARD_SIZE):
                self.all_pos_verti.append(pos)
            self.rect.left = random.choice(self.all_pos_hori)
            self.rect.top = random.choice(self.all_pos_verti)




            print(self.rect)
